__author__ = 'lenovo'
#encoding=utf-8
import py_code_replace
import wx


class Frame(wx.Frame):
    def __init__(self, parent, id, title):
        x = 10
        y = 10
        wx.Frame.__init__(self, parent, id, title, size=(500, 500))
        panel = wx.Panel(self, -1) #创建画板

        wx.StaticText(panel, -1, u"文件：", pos=(x + 10, y + 10))
        self.fileEdit = wx.TextCtrl(panel, size=(270, 25), pos=(x + 70, y + 10))
        self.fileBtn = wx.Button(panel, label='...', size=(30, 25), pos=(x + 340, y + 10))
        self.Bind(wx.EVT_BUTTON, self.OnGetFilePath, self.fileBtn)
        wx.StaticText(panel, -1, u"函数：", pos=(x + 10, y + 60))
        self.funEdit = wx.TextCtrl(panel, size=(300, 50), pos=(x + 70, y + 45))

        wx.StaticText(panel, -1, u"宏定义：", pos=(x + 10, y + 140))
        self.content = wx.TextCtrl(panel, size=(300, 200), pos=(x + 70, y + 110))

        self.btnSwitch = wx.Button(panel, label=u'转换', pos=(x + 100, y + 350))
        self.btnClose = wx.Button(panel, label='Close', pos=(x + 200, y + 350))
        self.Bind(wx.EVT_BUTTON, self.OnSwitch, self.btnSwitch)
        self.Bind(wx.EVT_BUTTON, self.OnCloseWin, self.btnClose)

    def OnSwitch(self, event):
        pass
    def OnGetFilePath(self, event):
        dlg = wx.FileDialog(self, "Choose File", "e:\\"
                            , r'1.txt',"All files (*.*)|*.*", wx.FD_OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            self.fileEdit.SetValue(dlg.GetPath())
        dlg.Destroy()
        
    def OnCloseWin(self, event):
        self.Destroy()

class App(wx.App):
    def OnInit(self):
        self.frame = Frame(parent=None, id=-1, title='Spare')
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True


if __name__ == '__main__':
    app = App()
    app.MainLoop()
